#pragma once
#include <vector>
#include "Tile.h"
#include <sfml/Window.hpp>
#include <sfml/System.hpp>
#include "TilePlotter.h"
#include "Camera.h"
#include "MouseMap.h"

class TileManager
{
public:
	TileManager();
	~TileManager();

	inline void SetRenderTarget(sf::RenderWindow* target) {window = target;}
	void SetMapSize(int w, int h);
	inline void SetCamera(Camera* cam) {camera = cam;}
	inline void SetWindow(sf::RenderWindow* window) { this->window = window; }

	inline const sf::Vector2i& GetMapSize() { return mapsize; }
	inline const sf::Vector2f& GetTileSize() { return tilesize; }

	int WorldToIso2(const sf::Vector2f& pos);
	int WorldToIso2(float x, float y);
	sf::Vector2i WorldToIso(const sf::Vector2f& pos);
	sf::Vector2i WorldToIso(float x, float y);

	const std::vector<Tile*>& GetTiles() const { return m_tiles; }

	void Draw();


	//TODO: figure out how to make the level loading
	void LoadLevel();
	void FreeLevel();

private:
	sf::RenderWindow* window;
	sf::Vector2i mapsize;
	sf::Vector2f tilesize;
	std::vector<Tile*> m_tiles;
	std::vector<std::vector<uint32> > m_tileGrid;
	Camera* camera;
	MouseMap mmap;
};
